//Granify Android SDK/com.granifyinc.granifysdk/Granify/trackPageView

trackPageView

[androidJvm]\

@JvmOverloads

@JvmStatic

fun trackPageView(pageIdentifier: PageIdentifier, activity: FragmentActivity, navigator: Navigator, safeArea: () -> SliderMargins?? = null, scrollableView: ScrollableView? = null, pageRestrictionState: RestrictionState = RestrictionState.UNRESTRICTED)

Tracks any changes to the active "page" or view that is displayed to the user in the application.

It is important to keep Granify notified about the current page and the shopper’s navigation through the app so that our engine can make appropriate decisions about what messages should be shown to which shoppers for maximum impact. This includes tracking what the user is currently viewing on the page via the use of scroll distance metrics which are inferred from the main scrollable view for the page.

Placement

This function should be called:

It is recommended to call trackPageView in the onResume lifecycle callback of an Activity or onResume lifecycle callback of a Fragment. Granify requires access to the current FragmentActivity at all times, so calling trackPageView from onResume ensures it is always available even when the activity is recreated due to a configuration change.

Note that any modifications to the Window.Callback of an activity must be made before a trackPageView call; otherwise, Granify will not be able to capture touch events.

Parameters

androidJvm

   
pageIdentifier A PageIdentifier object containing the page type of the current page and its path.
activity The current activity. Granify requires the current activity for displaying campaign fragments and for capturing touch data.
navigator Class implementing Navigator, providing functions to navigate to different pages within the application.
scrollableView The main ScrollableView on the page. These must be passed through the provided wrapper classes such as ScrollViewWrapper.
safeArea A closure that returns SliderMargins where the margins given dictate the area where it is safe to draw a slider. This ensures a slider does not block app functionality such as navigation. If your app has a navbar displayed at the bottom of the activity, a sample SliderMargins to use is SliderMargins(left: 0, top: 0, right: 0, bottom: navBar.height). The closure passed into this method will be invoked on the main thread whenever an orientation change of the device or an activity change occurs to allow the Granify widgets to always use an up-to-date safe area for display.
pageRestrictionState a RestrictionState indicating whether or not the page is eligible to have a slider displayed on it. This parameter is not required, and defaults to UNRESTRICTED.

[androidJvm]\

@JvmStatic

fun trackPageView(pageIdentifier: PageIdentifier, activity: FragmentActivity, navigator: Navigator, safeArea: SliderMargins? = null, scrollableView: ScrollableView? = null, pageRestrictionState: RestrictionState = RestrictionState.UNRESTRICTED)


Deprecated

Do not pass in safeArea as SliderMargins, safeArea should now be passed as a closure that returns SliderMargins.

Replace with

Granify.trackPageView(
        pageIdentifier: PageIdentifier,
        activity: FragmentActivity,
        navigator: Navigator,
        safeArea: (() -> SliderMargins?)? = null,
        scrollableView: ScrollableView? = null,
        pageRestrictionState: RestrictionState = RestrictionState.UNRESTRICTED
)

Tracks any changes to the active "page" or view that is displayed to the user in the application.

It is important to keep Granify notified about the current page and the shopper’s navigation through the app so that our engine can make appropriate decisions about what messages should be shown to which shoppers for maximum impact. This includes tracking what the user is currently viewing on the page via the use of scroll distance metrics which are inferred from the main scrollable view for the page.

Placement

This function should be called:

It is recommended to call trackPageView in the onResume lifecycle callback of an Activity or onResume lifecycle callback of a Fragment. Granify requires access to the current FragmentActivity at all times, so calling trackPageView from onResume ensures it is always available even when the activity is recreated due to a configuration change.

Note that any modifications to the Window.Callback of an activity must be made before a trackPageView call; otherwise, Granify will not be able to capture touch events.

Parameters

androidJvm

   
pageIdentifier A PageIdentifier object containing the page type of the current page and its path.
activity The current activity. Granify requires the current activity for displaying campaign fragments and for capturing touch data.
navigator Class implementing Navigator, providing functions to navigate to different pages within the application.
scrollableView The main ScrollableView on the page. These must be passed through the provided wrapper classes such as ScrollViewWrapper.
safeArea A SliderMargins where the margins given dictate the area where it is safe to draw a slider. This ensures a slider does not block app functionality such as navigation. If your app has a navbar displayed at the bottom of the activity, a sample SliderMargins to use is SliderMargins(left: 0, top: 0, right: 0, bottom: navBar.height).
pageRestrictionState a RestrictionState indicating whether or not the page is eligible to have a slider displayed on it. This parameter is not required, and defaults to UNRESTRICTED.